<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" session="false" %>
<html>
<head>
    <title>智能锁用户信息注册</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/css/select2.min.css"
          rel="stylesheet">
    <!-- jqgrid-->
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/custom.ui.jqgrid.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/style.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/i18n/grid.locale-cn.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/minified/jquery.jqGrid.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/extend/layer.ext.js"
            type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/js/select2.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/global.js"></script>	
    <style type="text/css">
    .re{
    	width: 90%;
    	font-size: 25px;
    	margin-top: 15px;
    	margin: 0 auto;
    }
    .div1{
        margin: 0 auto;
    	width: 50%;
    	border: 1px solid #ccc;
    	border-radius: 0px 0px 20px 20px;
    }
    .div2{
        margin: 0 auto;
        padding: 10px 1px 5px 1px;
    	width: 50%;
    	border: 1px solid #ccc;
    	border-radius: 20px 20px 0px 0px;
    	margin-top: 5%;
    	
    }
    </style>
</head>
<body>
<div class="">
    <div class="icon">
        <a class="icon-title">ZHANG
            LIAN</a>
    </div>
    <div class="top_left">
        <h5>
            <span>智能锁管理平台</span>
        </h5>
    </div>
</div>
<div class="div2">
		<div class="re"><span >注册智能锁管理</span></div>
</div>
<div class="div1">
    <div class="form-horizontal m-t">
        <input class="form-control" name="agtcode" id="agtcode" size="30" disabled="disabled" style="display: none;"/>
        <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>用户姓名:</label>
            <div class="col-sm-8">
                <input class="form-control" name="communityName" id="communityName" placeholder="请填写用户姓名" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>用户账号:</label>
            <div class="col-sm-8">
                <input class="form-control" name="adminUser" id="adminUser" placeholder="填写有效手机号，用于登录系统、找回密码" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>登录密码:</label>
            <div class="col-sm-8">
                 <input class="form-control" type="password" name="comm" placeholder="请输入密码，密码为6-16位，字母、数字或英文符号" id="comm"size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>确认密码:</label>
            <div class="col-sm-8">
                 <input class="form-control" type="password" name="againPassword" id="againPassword" placeholder="请再次输入密码" size="30"/>
            </div>
        </div>
<!--         <div class="form-group">
	        <label class="col-sm-3 control-label"><i class="require">*</i>联系人:</label>
	        <div class="col-sm-8">
	            <input class="form-control" name="comContact" id="comContact" placeholder="请填写联系人名称，中文或英文" size="30"/>
	        </div>
	    </div>
	    <div class="form-group">
	        <label class="col-sm-3 control-label"><i class="require">*</i>联系方式:</label>
	        <div class="col-sm-8">
	            <input class="form-control" name="departTel" id="departTel" placeholder="请填写联系人手机号" size="30"/>
	
	        </div>
	    </div> -->
        <div class="form-group">
	        <label class="col-sm-3 control-label"><i class="require">*</i>所属区域:</label>
	        <div class="col-sm-8" id="region">
	            <script type="text/javascript">
	                loadRegions();
	            </script>
	        </div>
    	</div>
       <div class="form-group">
            <label class="col-sm-3  control-label">用户详细地址:</label>
            <div class="col-sm-8">
                <input class="form-control" name="street" id="street" placeholder="填写用户详细地址" size="30"/>
            </div>
        </div>
       <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>PID:</label>
            <div class="col-sm-8">
                <input class="form-control" name="pid" id="pid" placeholder="购买锁的PID" size="30"/>
            </div>
        </div>
       <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>激活码:</label>
            <div class="col-sm-8">
                <input class="form-control" name="checkCode" id="checkCode" placeholder="锁的验证码信息" size="30"/>
            </div>
        </div>
       <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>自定义智能锁名称:</label>
            <div class="col-sm-8">
                <input class="form-control" name="lockName" id="lockName" placeholder="该智能锁名称，如:我的大门、紫金华苑501等" size="10"/>
            </div>
        </div>
        <div style="text-align: center;margin: 30px;">
             <input class="btn btn-success form-control"  type="button"  onclick="cancle()"  style="width: 150px;margin-right: 70px;" value="返回登录">
             <input class="btn btn-success form-control"  type="button" id="sub" onclick="checkTail()"  style="width: 150px;" value="提交">
        </div>
    </div>
</div>
<script>
	function cancle(){
		window.location.href = "${pageContext.request.contextPath}/admin/login.action";
	}
	function checkTail(){
		$("#sub").attr("disabled", "true");
		var adminUser = $("#adminUser").val();
	    var password = $("#comm").val();
	    var againPassword = $("#againPassword").val();
	    var communityName = $("#communityName").val();
	    //var comContact = $("#comContact").val();
	    //var departTel = $("#departTel").val();
	    var selects=document.getElementsByName('areaCode');
        var areaCode = selects[0].value;
        var cityCode = $("#cityCode").val();
	    var street = $("#street").val();
	    var checkCode = $("#checkCode").val();
	    var pid = $("#pid").val();
	    var lockName = $("#lockName").val();
	    if(!communityName){
	    	 alert("用户姓名必填");
	    	 $("#sub").removeAttr("disabled");
	    	 return;
	    }
	    if(!adminUser){
	    	 alert("用户账号必填");
	    	 $("#sub").removeAttr("disabled");
	    	 return;
	    }else if(!(/^1[3|4|5|7|8]\d{9}$/.test(adminUser))){ 
	        alert("用户账号有误，请填写手机号格式"); 
	        $("#sub").removeAttr("disabled");
	        return; 
	    }
	    
	    if(!password){
	    	 alert("登录密码必填");
	    	 $("#sub").removeAttr("disabled");
	    	 return;
	    }else if(!(/^[A-Za-z_0-9\x21-\x7e]{6,16}$/.test(password))){
	    	 alert("登录密码有误，请填写6-16位，字母、数字或英文符号"); 
	         $("#sub").removeAttr("disabled");
	         return; 
	    }
	    
	    if(!againPassword){
	    	alert("确认密码必填");
	   		$("#sub").removeAttr("disabled");
	   	 	return;
	    }else if(password != againPassword){
	   	 	alert("确认密码和登录密码不匹配"); 
	     	$("#sub").removeAttr("disabled");
	     	return; 
		}
/* 	    if(!comContact){
	    	 alert("联系人姓名必填");
	    	 $("#sub").removeAttr("disabled");
	    	 return;
	    }else if(!(/^[a-zA-Z\u4e00-\u9fa5]*$/.test(comContact))){
	      	 alert("联系人姓名有误，请填写中文或者英文"); 
	         $("#sub").removeAttr("disabled");
	         return; 
	    } 
	    if(!departTel){
	    	 alert("联系方式必填");
	    	 $("#sub").removeAttr("disabled");
	    	 return;
	    }else if(!(/^1[3|4|5|7|8]\d{9}$/.test(departTel))){ 
	        alert("联系方式有误，请填写手机号格式"); 
	        $("#sub").removeAttr("disabled");
	        return; 
	    }
	    */
	    if(!areaCode){
	    	 alert("所属区域必填");
	    	 $("#sub").removeAttr("disabled");
	    	 return;
	    }
	    if(!pid){
	    	 alert("购买锁的PID必填");
	    	 $("#sub").removeAttr("disabled");
	    	 return;
	    }
	    if(!checkCode){
	    	 alert("锁的验证码信息必填");
	    	 $("#sub").removeAttr("disabled");
	    	 return;
	    }
	    $.post("${pageContext.request.contextPath}/register/tComuLockAdd.action", {
	    	'typeAPP': '1',
	    	'adminUser': adminUser,
		    'comm': password,
		    'communityName': communityName,
		    //'comContact': comContact,
		    //'departTel': departTel,
	        'areaCode': areaCode,
	        'cityCode':cityCode,
		    'street': street,
		    'pid': pid,
		    'checkCode': checkCode,
		    'lockName': lockName
         }, function (result) {
             result = JSON.parse(result)
             if (result.code == 1) {
            	 layer.alert(result.msg);
            	 window.location.href = "${pageContext.request.contextPath}/admin/login.action";
             }else{
            	 $("#sub").removeAttr("disabled");
             	layer.alert(result.msg);
             }
         });
	}
	
</script>
</body>
</html>

